/**
 * HelloSpeakerProxy.java is created by Zachariah at 2012-2-2 下午05:40:55
 */
package com.zack.designPattern.proxy.staticproxy;

/**
 * @author zachariah zzcfrog@gmail.com
 *
 */
public class HelloSpeakerProxy implements Speaker {

	private Speaker speaker;
	
	public HelloSpeakerProxy(String name){
		this.speaker = new HelloSpeaker(name);
	}
	
	/**
	 * @see com.zack.designPattern.proxy.staticproxy.Speaker#say(java.lang.String)
	 */
	@Override
	public void say(String words) {
		if("john".equals(speaker.getName())){
			speaker.say(words);
		}else{
			System.out.println("u aren't allowed to speak!");
		}

	}

	/**
	 * @see com.zack.designPattern.proxy.staticproxy.Speaker#getName()
	 */
	@Override
	public String getName() {
		return this.speaker.getName();
	}

}
